package de.tum.in.eist.im.client.GUIwidgets;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.TextBox;

/*
 * Just a small DialogBox to inform the User about important things!
 * Basically instead of avoid Window.alert();
 */
public class UserDialog {
	protected DialogBox inviteDialog = new DialogBox();;
	protected HorizontalPanel panel = new HorizontalPanel();

	protected Button OKButton = new Button("OK");
	protected Button cancelButton = new Button("Cancel");
	protected TextBox inputBox = new TextBox();

	protected String text;

	public UserDialog(String text) {
		inviteDialog.setText(text);
		
		panel.add(OKButton);
		
		OKButton.setFocus(true);
		
		inviteDialog.setWidget(panel);
		inviteDialog.setPopupPosition(300, 300);
		inviteDialog.show();
		inviteDialog.setModal(false);

		Timer t = new Timer() {
			public void run() {
				inviteDialog.hide();
			}
		};
		t.schedule(10000);

		
		addHandlerToWidgets();
	}

	private void addHandlerToWidgets() {
		OKButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				inviteDialog.hide();
			}
		});
	}
}
